******************************************
*
*	Article: The Human Costs of the War on Drugs: Attitudes towards Militarization of Security in Mexico
*	Authors: Juan Masullo J., Davide Morisi
*	Journal: Comparative Political Studies
*	Date: 23 March 2023
*
*	This file replicates the following
*	ANALYSIS STUDY 3 (APPENDIX C + MAIN FIGURES)
*
*	All analyses performed with Stata/SE 14.2 for Windows
******************************************

*Set working directory
*[my working directory]

*Open dataset
use "Replication_CPS\Data\study3_recoded.dta", clear

global PathRES = "Replication_CPS\"

*Covariates
global demo_st3 "i.female age10 i.edu4 trust_army01 i.regions"


*
*Table C1. Summary statistics
tab edu4, gen(edu_cat)
tab regions, gen(region_cat)
tab group, gen(group_cat)
*table
eststo clear
estpost sum dv_att female age edu_cat* victim_cartel trust_army01 region_cat* group_cat*
esttab using "${PathRES}TableC1.rtf", cells("count mean sd min max") replace
sum age, d
*drop created var
drop edu_cat* region_cat* group_cat*

*
*Table C2. Balance tests
eststo clear
mlogit group $demo_st3 i.victim_cartel, b(1)
esttab using "${PathRES}TableC2.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("TableC2. Study 3 - balance checks") compress noeqlines replace

*
*Table C3. Average treatment effects
eststo clear
eststo: reg dv_att i.group
eststo: reg dv_att i.group $demo_st3 i.victim_cartel
eststo: reg dv_att i.group##ib1.attention_correct
eststo: reg dv_att i.group##ib1.attention_correct $demo_st3 i.victim_cartel
esttab using "${PathRES}TableC3.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("TableC3. Study 3 - Average treatment effects") wide compress noeqlines replace 
*standardized dv
eststo clear
eststo: reg st_dv_att i.group
eststo: reg st_dv_att i.group $demo_st3 i.victim_cartel
eststo: reg st_dv_att i.group##ib1.attention_correct
eststo: reg st_dv_att i.group##ib1.attention_correct $demo_st3 i.victim_cartel
esttab using "${PathRES}TableC3st.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("TableC3. Study 3 - Average treatment effects") wide compress noeqlines replace 


****************
*Figure 5: Effects of arguments (Study 3)

reg dv_att i.group $demo_st3 i.victim_cartel
eststo all_sample: margins, dydx(2.group 3.group) post
reg dv_att i.group##ib1.attention_correct $demo_st3 i.victim_cartel
eststo correct: margins, dydx(2.group 3.group) at(attention_correct==1) post
*graph
coefplot (all_sample, ciopts(lcolor(dkgreen)) mcolor(dkgreen) msymbol(O) msize(medlarge))  ///
(correct, ciopts(lcolor(teal)) mcolor(teal) msymbol(D) msize(medlarge)), ///
vertical yline(0) ytitle("Effects on support for militarization") ///
levels(90 95) graphregion(color(white)) ///
name(graph1, replace)

